package jp.sinya;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 重定向
 */
public class DemoServlet4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //【方法二】
        //resp.setHeader("Location", "/Demo1/demo5");
        //设置statusCode 这句话一定要写在header之后
        //resp.setStatus(302);

        //【方法一】快捷重定向方法
        //resp.sendRedirect("http://www.baidu.com");
        resp.sendRedirect("/Demo1/demo5");
    }
}
